package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("配置文件已经生效");

        String musicPath="D:\\javacode\\webdemo\\src\\main\\resources\\static\\mp3\\";
        String imgPath="D:\\javacode\\webdemo\\src\\main\\resources\\static\\img\\";
        registry.addResourceHandler("/mp3/**").addResourceLocations("file:"+musicPath);
        registry.addResourceHandler("/img/**").addResourceLocations("file:"+imgPath);

    }
}
